Method for Synchronizing Network Device, and Network Device

ABSTRACT

A method for synchronizing a network device includes: receiving, by the network device, a first SSM and a second SSM, where the first SSM carries a first SSM code for indicating a quality level of a first clock source and a first eSSM code for indicating the quality level of the first clock source, and the second SSM carries a second SSM code for indicating a quality level of a second clock source and a second eSSM code for indicating the quality level of the second clock source. When a value of the first SSM code is less than a value of the second SSM code, the network device calibrates a frequency of the network device based on a timing signal of the first clock source.

CROSS-REFERENCE TO RELATED APPLICATIONS

This is a continuation of Int'l Patent App. No. PCT/CN2017/116955 filedon Dec. 18, 2017, which is incorporated by reference.

TECHNICAL FIELD

The present disclosure relates to the field of communicationstechnologies, and in particular, to a method for synchronizing a networkdevice, and a network device.

BACKGROUND

A format of a quality-level type-length-value (QL TLV) is defined inG.8264/Y.1364, May 2014, released by the International TelecommunicationUnion Telecommunication Standardization Sector (ITU-T). Asynchronization status message (SSM) code may be carried in the QL TLV.A format of an extended QL TLV is defined in G.8264/Y.1364 Amendment 2,April 2016, released by the ITU-T. An enhanced SSM (eSSM) code may becarried in the extended QL TLV. When a network device receives aplurality of messages that comply with G.8264/Y.1364 Amendment 2 and areseparately used to indicate quality levels of different clock sources,G.8264/Y.1364 Amendment 2 does not specify how to select a clock sourcefor tracking from a plurality of clock sources. As a result, the networkdevice cannot select a clock source (synchronization source) havingrelatively high synchronization precision from the plurality of clocksources.

SUMMARY

This disclosure provides a method for synchronizing a network device, anetwork device, a computer program product, and a system. According tothe foregoing technical solutions, the network device can select a clocksource having relatively high synchronization precision.

According to a first aspect, a method for synchronizing a network deviceis provided.

The method includes: receiving, by the network device, a first SSM and asecond SSM, where the first SSM carries a first SSM code for indicatinga quality level of a first clock source and a first eSSM code forindicating the quality level of the first clock source, and the secondSSM carries a second SSM code for indicating a quality level of a secondclock source and a second eSSM code for indicating the quality level ofthe second clock source.

The method further includes: calibrating, by the network device, afrequency of the network device based on a timing signal of the firstclock source when a value of the first SSM code is less than a value ofthe second SSM code.

G.8264/Y.1364 defines a set of clock quality levels. For example, theclock quality levels defined by G.8264/Y.1364 include qualitylevel-primary reference clock (QL-PRC), quality level-type I or V slaveclock (QL-SSU-A), quality level-type VI slave clock (QL-SSU-B), qualitylevel-synchronous equipment clock (QL-SEC), and quality level-do not use(QL-DNU). For QL-PRC, QL-SSU-A, QL-SSU-B, QL-SEC, and QL-DNU. Refer toG.781 and G.8264. In addition, according to G.8264/Y.1364, a smallervalue of an SSM code corresponds to a higher quality level of a clocksource.

When the value of the first SSM code is less than the value of thesecond SSM code, the quality level of the first clock source is higherthan the quality level of the second clock source. Therefore, incomparison with tracking the second clock source, the network device canobtain a frequency with higher precision by tracking the first clocksource.

In addition, G.8264/Y.1364 Amendment 2 defines an eSSM code. When aquality level of a clock source is a clock quality level defined byG.781, a value of an eSSM code for indicating the quality level of theclock source is equal to 0xFF. For example, assuming that the qualitylevel of the first clock source is QL-EEC1 and the quality level of thesecond clock source is QL-PRC, a value of an SSM code corresponding tothe first clock source is equal to 0xB, and a value of an SSM codecorresponding to the second clock source is equal to 0x2. A value of aneSSM code corresponding to the first clock source is equal to 0xFF, anda value of an eSSM code corresponding to the second clock source isequal to 0xFF. To be specific, if the network device supports onlyG.8264/Y.1364 and does not support G.8264/Y.1364 Amendment 2, thenetwork device determines, based on a fact that the value of the firstSSM code is greater than the value of the second SSM code, that thequality level of the first clock source is lower than the quality levelof the second clock source. However, if the network device supports onlyspecification of the eSSM code in G.8264/Y.1364 Amendment 2 and does notsupport a specification of the SSM code in G.8264/Y.1364, the networkdevice determines, based on a fact that a value of the first eSSM codeis equal to a value of the second eSSM code, that the quality level ofthe first clock source is the same as the quality level of the secondclock source. To be specific, although quality levels of the first clocksource and the second clock source are actually different, ifdetermining is based only on the values of the eSSM codes, the qualitylevels of the first clock source and the second clock source are thesame.

Based on the foregoing analysis, when the value of the first SSM code isdifferent from the value of the second SSM code, in comparison withdetermining a to-be-tracked clock source based on the values of the eSSMcodes, the network device can track a clock source with higher precisionby determining a to-be-tracked clock source based on the values of theSSM codes. Specifically, when the value of the first SSM code is lessthan the value of the second SSM code, it is determined that a clocksource corresponding to an SSM code having a smaller value, that is, thefirst clock source, is the to-be-tracked clock source, so that thenetwork device can track a clock source with higher precision.

Optionally, in the foregoing technical solution, the method furtherincludes: calibrating, by the network device, the frequency of thenetwork device based on the timing signal of the first clock source whenthe value of the first SSM code is equal to the value of the second SSMcode and the value of the first eSSM code is less than the value of thesecond eSSM code.

When the value of the first SSM code is equal to the value of the secondSSM code, if determining is based only on the values of the SSM codes,the quality level of the first clock source is equal to the qualitylevel of the second clock source. However, the quality level of thefirst clock source is actually higher than the quality level of thesecond clock source.

Therefore, in the foregoing technical solution, when the value of thefirst SSM code is equal to the value of the second SSM code, the clocksource with higher precision can be determined based on the values ofthe eSSM codes.

Optionally, in the foregoing technical solution, the method furtherincludes: calibrating, by the network device, the frequency of thenetwork device based on the timing signal of the first clock source whenthe value of the first SSM code is equal to the value of the second SSMcode, the value of the first eSSM code is equal to the value of thesecond eSSM code, and a value of the number of cascaded synchronousEthernet equipment clocks (EECs) from a nearest synchronization supplyunit/primary reference clock (SSU/PRC) in the first SSM is less than avalue of the number of cascaded synchronous Ethernet equipment clocksfrom the nearest synchronization supply unit/primary reference clock inthe second SSM.

In the foregoing technical solution, when the value of the first SSMcode is equal to the value of the second SSM code and the value of thefirst eSSM code is equal to the value of the second eSSM code, thenetwork device can select, from a plurality of clock sources, a clocksource for calibrating the frequency of the network device, to avoid afailure to determine the clock source. For example, the failure todetermine the clock source may result in low precision of a clock of thenetwork device, and may even result in a service interruption of thenetwork device.

Optionally, in the foregoing solution, the method further includes:calibrating, by the network device, the frequency of the network devicebased on the timing signal of the first clock source when the value ofthe first SSM code is equal to the value of the second SSM code, thevalue of the first eSSM code is equal to the value of the second eSSMcode, the value of the number of cascaded synchronous Ethernet equipmentclocks from the nearest synchronization supply unit/primary referenceclock in the first SSM is equal to the value of the number of cascadedsynchronous Ethernet equipment clocks from the nearest synchronizationsupply unit/primary reference clock in the second SSM, and a value ofthe number of cascaded enhanced synchronous Ethernet equipment clocksfrom the nearest SSU/PRC in the first SSM is less than a value of thenumber of cascaded enhanced synchronous Ethernet equipment clocks fromthe nearest synchronization supply unit/primary reference clock in thesecond SSM.

Optionally, in the foregoing technical solution, the method furtherincludes: calibrating, by the network device, the frequency of thenetwork device based on the timing signal of the first clock source whenthe value of the first SSM code is equal to the value of the second SSMcode, the value of the first eSSM code is equal to the value of thesecond eSSM code, the value of the number of cascaded synchronousEthernet equipment clocks from the nearest synchronization supplyunit/primary reference clock in the first SSM is equal to the value ofthe number of cascaded synchronous Ethernet equipment clocks from thenearest synchronization supply unit/primary reference clock in thesecond SSM, the value of the number of cascaded enhanced synchronousEthernet equipment clocks from the nearest synchronization supplyunit/primary reference clock in the first SSM is equal to the value ofthe number of cascaded enhanced synchronous Ethernet equipment clocksfrom the nearest synchronization supply unit/primary reference clock inthe second SSM, and a value of a synchronous Ethernet master identity(SyncE master ID) in the first SSM is less than a value of a SyncEMaster ID in the second SSM.

According to a second aspect, a network device is provided. The networkdevice includes a receiving unit and a calibration unit.

The receiving unit is configured to receive a first SSM and a secondSSM, where the first SSM carries a first SSM code for indicating aquality level of a first clock source and a first eSSM code forindicating the quality level of the first clock source, and the secondSSM carries a second SSM code for indicating a quality level of a secondclock source and a second eSSM code for indicating the quality level ofthe second clock source.

The calibration unit is configured to calibrate a frequency of thenetwork device based on a timing signal of the first clock source when avalue of the first SSM code is less than a value of the second SSM code.

Optionally, in the foregoing technical solution, the calibration unit isfurther configured to calibrate the frequency of the network devicebased on the timing signal of the first clock source when the value ofthe first SSM code is equal to the value of the second SSM code and thevalue of the first eSSM code is less than the value of the second eSSMcode.

Optionally, in the foregoing technical solution, the calibration unit isfurther configured to calibrate the frequency of the network devicebased on the timing signal of the first clock source when the value ofthe first SSM code is equal to the value of the second SSM code, thevalue of the first eSSM code is equal to the value of the second eSSMcode, and a value of the number of cascaded synchronous Ethernetequipment clocks from a nearest synchronization supply unit/primaryreference clock in the first SSM is less than a value of the number ofcascaded synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the second SSM.

Optionally, in the foregoing technical solution, the calibration unit isfurther configured to calibrate the frequency of the network devicebased on the timing signal of the first clock source when the value ofthe first SSM code is equal to the value of the second SSM code, thevalue of the first eSSM code is equal to the value of the second eSSMcode, the value of the number of cascaded synchronous Ethernet equipmentclocks from the nearest synchronization supply unit/primary referenceclock in the first SSM is equal to the value of the number of cascadedsynchronous Ethernet equipment clocks from the nearest synchronizationsupply unit/primary reference clock in the second SSM, and a value ofthe number of cascaded enhanced synchronous Ethernet equipment clocksfrom the nearest synchronization supply unit/primary reference clock inthe first SSM is less than a value of the number of cascaded enhancedsynchronous Ethernet equipment clocks from the nearest synchronizationsupply unit/primary reference clock in the second SSM.

Optionally, in the foregoing technical solution, the calibration unit isfurther configured to calibrate the frequency of the network devicebased on the timing signal of the first clock source when the value ofthe first SSM code is equal to the value of the second SSM code, thevalue of the first eSSM code is equal to the value of the second eSSMcode, the value of the number of cascaded synchronous Ethernet equipmentclocks from the nearest synchronization supply unit/primary referenceclock in the first SSM is equal to the value of the number of cascadedsynchronous Ethernet equipment clocks from the nearest synchronizationsupply unit/primary reference clock in the second SSM, the value of thenumber of cascaded enhanced synchronous Ethernet equipment clocks fromthe nearest synchronization supply unit/primary reference clock in thefirst SSM is equal to the value of the number of cascaded enhancedsynchronous Ethernet equipment clocks from the nearest synchronizationsupply unit/primary reference clock in the second SSM, and a value of aSyncE Master ID in the first SSM is less than a value of a SyncE MasterID in the second SSM.

According to a third aspect, a network device is provided. The networkdevice includes a transceiver, a processor, and a memory. Thetransceiver is coupled to the processor, the processor is coupled to thememory, and the memory stores a computer program.

The transceiver is configured to receive a first SSM and a second SSM,where the first SSM carries a first SSM code for indicating a qualitylevel of a first clock source and a first eSSM code for indicating thequality level of the first clock source, and the second SSM carries asecond SSM code for indicating a quality level of a second clock sourceand a second eSSM code for indicating the quality level of the secondclock source.

When the computer program in the memory is executed, the processor isenabled to calibrate a frequency of the network device based on a timingsignal of the first clock source when a value of the first SSM code isless than a value of the second SSM code.

Optionally, in the foregoing technical solution, when the computerprogram in the memory is executed, the processor is further enabled tocalibrate the frequency of the network device based on the timing signalof the first clock source when the value of the first SSM code is equalto the value of the second SSM code and the value of the first eSSM codeis less than the value of the second eSSM code.

Optionally, in the foregoing technical solution, when the computerprogram in the memory is executed, the processor is further enabled tocalibrate the frequency of the network device based on the timing signalof the first clock source when the value of the first SSM code is equalto the value of the second SSM code, the value of the first eSSM code isequal to the value of the second eSSM code, and a value of the number ofcascaded synchronous Ethernet equipment clocks from a nearestsynchronization supply unit/primary reference clock in the first SSM isless than a value of the number of cascaded synchronous Ethernetequipment clocks from the nearest synchronization supply unit/primaryreference clock in the second SSM.

Optionally, in the foregoing technical solution, when the computerprogram in the memory is executed, the processor is further enabled tocalibrate the frequency of the network device based on the timing signalof the first clock source when the value of the first SSM code is equalto the value of the second SSM code, the value of the first eSSM code isequal to the value of the second eSSM code, the value of the number ofcascaded synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the first SSM isequal to the value of the number of cascaded synchronous Ethernetequipment clocks from the nearest synchronization supply unit/primaryreference clock in the second SSM, and a value of the number of cascadedenhanced synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the first SSM isless than a value of the number of cascaded enhanced synchronousEthernet equipment clocks from the nearest synchronization supplyunit/primary reference clock in the second SSM.

Optionally, in the foregoing technical solution, when the computerprogram in the memory is executed, the processor is further enabled tocalibrate the frequency of the network device based on the timing signalof the first clock source when the value of the first SSM code is equalto the value of the second SSM code, the value of the first eSSM code isequal to the value of the second eSSM code, the value of the number ofcascaded synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the first SSM isequal to the value of the number of cascaded synchronous Ethernetequipment clocks from the nearest synchronization supply unit/primaryreference clock in the second SSM, the value of the number of cascadedenhanced synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the first SSM isequal to the value of the number of cascaded enhanced synchronousEthernet equipment clocks from the nearest synchronization supplyunit/primary reference clock in the second SSM, and a value of a SyncEMaster ID in the first SSM is less than a value of a SyncE Master ID inthe second SSM.

According to a fourth aspect, a computer program product is provided.The computer program product is stored in a non-volatile computerreadable storage medium or a volatile computer readable storage medium.When the computer program is executed, a computer or a processor isenabled to perform a method provided in the first aspect.

According to a fifth aspect, a computer readable storage medium isprovided, and the computer readable storage medium may be a non-volatilecomputer readable storage medium or a volatile computer readable storagemedium. The computer readable storage medium stores a computer programor code, and when the computer program or the code is executed, acomputer or a processor is enabled to perform a method provided in thefirst aspect.

According to a sixth aspect, a system is provided. The system includes afirst clock source, a second clock source, and a network device providedin the second aspect or the third aspect.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of a clock synchronization network.

FIG. 2 is a schematic diagram of a clock synchronization network.

FIG. 3 is a schematic flowchart of a method for synchronizing a networkdevice.

FIG. 4 is a schematic structural diagram of a network device.

FIG. 5 is a schematic structural diagram of a network device.

FIG. 6 is a schematic structural diagram of a network device.

FIG. 7 is a schematic structural diagram of a system.

DESCRIPTION OF EMBODIMENTS

G.8264/Y.1364 is a standard released by ITU-T in May 2014. G.8264/Y.1364Amendment 2 is a standard released by ITU-T in April 2016. G.781 is astandard released by ITU-T in September 2008.

The following describes technical solutions with reference to theaccompanying drawings.

FIG. 1 is a schematic diagram of a clock synchronization networkaccording to an embodiment. The clock synchronization network includes asatellite 10, a router 11, a router 12, a router 13, and a base station16. The satellite 10 may be a Global Positioning System (GPS) satellite.Alternatively, the satellite 10 may be a Global Navigation SatelliteSystem (GLONASS) satellite or a BeiDou Navigation Satellite Systemsatellite. The GPS satellite is used as an example in this embodiment.The router 11 may be a provider router. The router 12 may be a provideredge router. The router 13 may be a customer edge router. The router 11,the router 12, and the router 13 may provide a virtual private network(VPN) service. For example, the VPN service may be a Layer 2 VPN (L2VPN)service. It may be understood that, when the router 11, the router 12,and the router 13 provide the L2VPN service, another network device notshown in FIG. 1, for example a host, may be present. The host may be alaptop computer or a desktop computer. The base station 16 is a networkdevice in a cellular network. For example, the base station 16 may be aNodeB. The base station 16 can provide a wireless access service. It maybe understood that, when the base station 16 provides the wirelessaccess service, another network device not shown in FIG. 1, for examplea user equipment (UE), may be present. The user equipment may be acellular phone.

In the clock synchronization network shown in FIG. 1, the satellite 10is upstream of the clock synchronization network, and the base station16 is downstream of the clock synchronization network. An upstreamdevice may send a clock signal to a downstream device by using the clocksynchronization network. Specifically, the satellite 10 may perform aclock synchronization operation for the router 11. The satellite 10 maybe the GPS satellite. Specifically, the router 11 may include a buildingintegrated timing supply (BITS) clock. The BITS clock includes a GPSreceiver. The satellite 10 may include an atomic clock. The satellite 10may be driven by the atomic clock to send a GPS signal to the router 11.The GPS signal may include time data having the same precision as theatomic clock. After receiving the GPS signal, the GPS receiver in therouter 11 may synchronize a clock in the router 11 to the atomic clockin the GPS satellite based on the time data in the GPS signal.Specifically, the router 11 may synchronize time of the clock in therouter 11 to time of the atomic clock in the GPS satellite. In addition,the router 11 may synchronize a frequency of the clock in the router 11to a frequency of the atomic clock in the GPS satellite. In theforegoing process, the BITS clock may be a primary reference time clock(PRTC). After the clock of the router 11 is calibrated, the router 11may be used as a clock source to send timing information to anotherdevice, to calibrate clock of the another device. The clock source mayalso be referred to as a synchronization source. For example, the router11 may be a clock source supporting G.8264/Y.1364 Amendment 2. Forexample, when a quality level of the BITS clock included in the router11 is QL-PRTC, the router 11 may send an SSM to another device. A valueof an eSSM code included in the SSM is equal to 0x20. When a qualitylevel of the BITS clock included in the router 11 is QL-ePRTC, therouter 11 may send an SSM to another device. A value of the eSSM codeincluded in the SSM is equal to 0x21. If another device also supportsG.8264/Y.1364 Amendment 2, the another device may determine, based on aneSSM code in the received SSM, that a quality level of the router 11 isQL-PRTC or QL-ePRTC.

After the clock of the router 11 is calibrated, the router 11 may beused as a clock source of the another device. Specifically, the router11 may be used as a clock source to calibrate the clock of the anotherdevice. For example, both the router 11 and the router 12 may be devicesthat comply with G.8264/Y.1364 Amendment 2. The router 11 may calibratea frequency of a clock of the router 12 based on G.8264/Y.1364 Amendment2. Similarly, the router 12 may be used as a clock source to calibrate aclock of the router 13. The router 13 may be used as a clock source tocalibrate a clock of the base station 16. In the foregoing process, therouter 11 may be considered as a clock source of the router 13. If therouter 12 stops tracking the router 11, that is, when the router 12 isused as a free running clock, the router 12 may be considered as a clocksource of the router 13.

In the foregoing solution, the router 11, the router 12, and the router13 are located in a fixed network. The base station 16 is located in thecellular network. The router 13 may be located at the edge of the fixednetwork. Before the router 13 calibrates a frequency and time of a localclock of the base station 16, the router 13 needs to track a frequencyand time of the router 12, and synchronize a local clock of the router13 with the frequency and the time of the clock of the router 12 that isused as the clock source.

FIG. 2 is a schematic diagram of a clock synchronization networkaccording to an embodiment. The technical solution shown in FIG. 2 maybe obtained through extension based on the clock synchronization networkshown in FIG. 1. For content not mentioned in this embodiment, refer tothe description of the embodiment corresponding to FIG. 1. The followingmainly describes a difference between the technical solution shown inFIG. 2 and the technical solution shown in FIG. 1. The clocksynchronization network shown in FIG. 2 includes a satellite 10, arouter 11, a router 12, a router 13, a router 14, a router 15, a basestation 16, and a base station 17. In comparison with FIG. 1, the clocksynchronization network shown in FIG. 2 further includes the router 14,the router 15, and the base station 17. The router 14 may be a providerrouter. The router 15 may be a provider edge router. The base station 17is a network device in a cellular network.

The satellite 10 may perform a clock synchronization operation for therouter 14. For a process of performing the clock synchronizationoperation by the satellite 10 for the router 14, refer to the foregoingdescription of performing the clock synchronization operation by thesatellite 10 for the router 11. Details are not described herein. Aftera clock of the router 14 is calibrated, the router 14 may be used as aclock source to calibrate clock of another device. For example, therouter 14 supports G.8264/Y.1364. A quality level of the router 14 isQL-PRTC. The router 14 may calibrate a frequency of a clock of therouter 15 based on G.8264/Y.1364. The router 15 supports G.8264/Y.1364and does not support G.8264/Y.1364 Amendment 2. A quality level of therouter 15 is QL-EEC1 or QL-EEC2. Therefore, when the router 15 tracksthe router 14, a quality level indicated by an SSM code included in anSSM sent by the router 15 to a downstream device (for example, therouter 13) in the clock synchronization network is QL-PRC. When therouter 15 is a free running clock, a quality level indicated by an SSMcode included in an SSM sent by the router 15 to a downstream device(for example, the router 13) is QL-EEC1 or QL-EEC2.

According to FIG. 2, the router 13 is coupled to the router 12. Therouter 13 is coupled to the router 15. The router 13 is coupled to thebase station 16. The router 13 is coupled to the base station 17.Specifically, the router 13 includes a port 1, a port 2, a port 3, and aport 4. The port 1, the port 2, the port 3, and the port 4 may all beEthernet ports. The Ethernet port may be a fast Ethernet port, a GigabitEthernet port, or a higher rate Ethernet port. The router 13 may becoupled to the router 12 by using the port 1. The router 13 may becoupled to the router 15 by using the port 2. The router 13 may becoupled to the base station 16 by using the port 3. The router 13 may becoupled to the base station 17 by using the port 4. The router 13 mayreceive information about the clock source router 12 and router 15through the port 1 and the port 2, respectively.

Specifically, the router 15 supports G.8264/Y.1364 and does not supportG.8264/Y.1364 Amendment 2. When the router 15 is the free running clock,the router 13 receives, through the port 2, an SSM sent by the router15. An SSM code included in the SSM sent by the router 15 indicates thequality level of the clock source (the router 15). For example, a valueof the SSM code is 0xB, which indicates that the quality level of therouter 15 is QL-EEC1. Because the router 15 does not supportG.8264/Y.1364 Amendment 2, the SSM sent by the router 15 does notinclude an eSSM code. That is, the SSM sent by the router 15 does notinclude the eSSM code for indicating the quality level of the clocksource (the router 15).

Specifically, the router 12 supports G.8264/Y.1364 and G.8264/Y.1364Amendment 2. When the router 12 tracks the router 11, the router 13receives, through the port 1, an SSM sent by the router 12. An SSM codeincluded in the SSM sent by the router 12 indicates a quality level of aclock source (the router 11). For example, a value of the SSM code is0x2, which indicates that the quality level of the router 15 is QL-PRC.Because the router 12 supports G.8264/Y.1364 Amendment 2, the SSM sentby the router 12 includes an eSSM code. The eSSM code included in theSSM sent by the router 12 indicates a quality level of a clock source(the router 12). For example, a value of the eSSM code is 0x20, whichindicates that the quality level of the router 12 is QL-PRTC.

FIG. 3 is a schematic flowchart of a method for synchronizing a networkdevice according to an embodiment. The method includes S301 and S302.The method shown in FIG. 3 may be performed by a network device. Thenetwork device may be a router, a network switch, a firewall, a loadbalancer, a base station, a packet transport network (PTN) device, aserving General Packet Radio Service (GPRS) support node (SGSN), agateway GPRS support node (GGSN), a radio network controller (RNC), or abase station controller (BSC). The network device may include a slaveclock. The slave clock may be a synchronous Ethernet equipment slaveclock. For the synchronous Ethernet equipment slave clock, refer toRecommendation ITU-T G.8262/Y.1362, 2007. It may be understood that anoperation related to a clock signal and performed by the network deviceis actually performed by the slave clock. For example, the slave clockmay process a received SSM to determine a to-be-tracked clock source. Inaddition, after the to-be-tracked clock source is determined, the slaveclock may calibrate a frequency of the slave clock based on timinginformation from the clock source. The calibrating a frequency of theslave clock may specifically include: generating, by a phase-locked loopof the slave clock, a periodic output signal based on the timinginformation, where a phase of the periodic output signal is the same asa phase of a periodic input signal included in the timing information.The periodic output signal is an output signal of the phase-locked loop.The periodic input signal is an input signal of the phase-locked loop.

FIG. 4 is a schematic structural diagram of a specific implementation ofthe network device. Referring to FIG. 4, a network device 400 mayinclude a control board and a forwarding board. The control board may becoupled to the forwarding board by using a control channel. The receiverand the transmitter may be integrated or discrete. The control boardincludes the receiver, the transmitter, a central processing unit, amemory, and a phase-locked loop. The receiver may receive a signal fromthe forwarding board by using the control channel. The transmitter maysend information to the forwarding board by using the control channel.The receiver is coupled to the central processing unit. The receiver iscoupled to the phase-locked loop. The phase-locked loop is coupled tothe transmitter. The central processing unit is coupled to thetransmitter. The central processing unit is coupled to the memory. Thememory stores a computer program. The central processing unit mayexecute the computer program. The forwarding board includes atransceiver 1, a transceiver 2, a network processor, and a transceiver3. The transceiver 1 is coupled to the network processor. Thetransceiver 2 is coupled to the network processor. The network processoris coupled to the transceiver 3. The transceiver 1 includes a physicallayer device. The transceiver 2 includes a physical layer device. Thetransceiver 3 includes a physical layer device.

For example, specifically, the router 13 shown in FIG. 2 may be thenetwork device shown in FIG. 4. Specifically, the port 1 of the router13 may be located on the transceiver 1. Specifically, the port 2 of therouter 13 may be located on the transceiver 2. Specifically, the port 3of the router 13 may be located on the transceiver 3.

S301. The network device receives a first SSM and a second SSM.

The first SSM carries a first SSM code for indicating a quality level ofa first clock source and a first eSSM code for indicating the qualitylevel of the first clock source. The second SSM carries a second SSMcode for indicating a quality level of a second clock source and asecond eSSM code for indicating the quality level of the second clocksource.

S302. When a value of the first SSM code is less than a value of thesecond SSM code, the network device calibrates a frequency of thenetwork device based on a timing signal of the first clock source.

For example, the network device may include a synchronous Ethernetequipment slave clock. The network device may receive the first SSM andthe second SSM through different ports. A device sending the first SSMis referred to as a first device below, and a device sending the secondSSM is referred to as a second device below. The first device may be adevice that supports both G.8264/Y.1364 and G.8264/Y.1364 Amendment 2.When the first device tracks another device, the first clock source is adevice tracked by the first device. When the first device is a freerunning clock, the first clock source is the first device. The firstdevice supports G.8264/Y.1364, and therefore the first SSM sent by thefirst device carries the first SSM code. The first device supportsG.8264/Y.1364 Amendment 2, and therefore the first SSM sent by the firstdevice carries the first eSSM code.

The second device may be a device that supports both G.8264/Y.1364 andG.8264/Y.1364 Amendment 2. When the second device tracks another device,the second clock source is a device tracked by the second device. Whenthe second device is a free running clock, the second clock source isthe second device. The second device supports G.8264/Y.1364, andtherefore the second SSM sent by the second device carries the secondSSM code. The second device supports G.8264/Y.1364 Amendment 2, andtherefore the second SSM sent by the second device carries the secondeSSM code for indicating the quality level of the second clock source.

For example, the network device receives the first SSM and the secondSSM by using an Ethernet synchronization messaging channel (ESMC). Forthe ESMC, refer to the description of the ESMC in G.8264/Y.1364.

The first SSM or the second SSM may be an ESMC protocol data unit (PDU).For a format of the ESMC PDU, refer to Table 11-3 in G.8264/Y.1364. TheESMC PDU may include an extended QL TLV and a QL TLV. The QL TLV mayinclude an SSM code. That is, the first SSM code or the second SSM codeis carried in the QL TLV. For a format of the QL TLV, refer to Table11-4 in G.8264/Y.1364. The extended QL TLV may include an enhanced SSMcode. That is, the first eSSM code or the second eSSM code is carried inthe extended QL TLV. For a format of the extended QL TLV, refer to Table11-4.2 in G.8264/Y.1364 Amendment 2.

The value of the first SSM code is less than the value of the second SSMcode. To be specific, if the network device supports only G.8264/Y.1364and does not support G.8264/Y.1364 Amendment 2, the network devicedetermines, based on a fact that the value of the first SSM code is lessthan the value of the second SSM code, that the quality level of thefirst clock source is higher than the quality level of the second clocksource.

G.8264/Y.1364 defines a set of clock quality levels. For example, theclock quality levels defined by G.8264/Y.1364 include QL-PRC, QL-SSU-A,QL-SSU-B, QL-SEC, and QL-DNU. For QL-PRC, QL-SSU-A, QL-SSU-B, QL-SEC,and QL-DNU, refer to G.781 and G.8264. In addition, according toG.8264/Y.1364, a smaller value of an SSM code corresponds to a higherquality level of a clock source.

When the value of the first SSM code is less than the value of thesecond SSM code, the quality level of the first clock source is higherthan the quality level of the second clock source. Therefore, incomparison with tracking the second clock source, the network device canobtain a frequency with higher precision by tracking the first clocksource.

In addition, G.8264/Y.1364 Amendment 2 defines an eSSM code. When aquality level of a clock source is a clock quality level defined byG.781, a value of an eSSM code for indicating the quality level of theclock source is equal to 0xFF. For example, assuming that the qualitylevel of the first clock source is QL-EEC1 and the quality level of thesecond clock source is QL-PRC, a value of an SSM code corresponding tothe first clock source is equal to 0xB, and a value of an SSM codecorresponding to the second clock source is equal to 0x2. A value of aneSSM code corresponding to the first clock source is equal to 0xFF, anda value of an eSSM code corresponding to the second clock source isequal to 0xFF. To be specific, if the network device supports onlyG.8264/Y.1364 and does not support G.8264/Y.1364 Amendment 2, thenetwork device determines, based on a fact that the value of the firstSSM code is greater than the value of the second SSM code, that thequality level of the first clock source is lower than the quality levelof the second clock source. However, if the network device supports onlyspecification of the eSSM code in G.8264/Y.1364 Amendment 2 and does notsupport a specification of the SSM code in G.8264/Y.1364, the networkdevice determines, based on a fact that a value of the first eSSM codeis equal to a value of the second eSSM code, that the quality level ofthe first clock source is the same as the quality level of the secondclock source. To be specific, although quality levels of the first clocksource and the second clock source are actually different, ifdetermining is based only on the values of the eSSM codes, the qualitylevels of the first clock source and the second clock source are thesame.

Based on the foregoing analysis, when the value of the first SSM code isdifferent from the value of the second SSM code, in comparison withdetermining a to-be-tracked clock source based on the values of the eSSMcodes, the network device can track a clock source with higher precisionby determining a to-be-tracked clock source based on the values of theSSM codes. Specifically, when the value of the first SSM code is lessthan the value of the second SSM code, it is determined that a clocksource corresponding to an SSM code having a smaller value, that is, thefirst clock source, is the to-be-tracked clock source, so that thenetwork device can track a clock source with higher precision.

The following describes the method shown in FIG. 3 by using an examplewith reference to FIG. 2 and FIG. 4.

The network device related to the method shown in FIG. 3 may be thenetwork device 400. The network device 400 shown in FIG. 4 may be therouter 13 in FIG. 2. The first clock source is the router 12. The secondclock source is the router 15. The port 1 and the port 2 are located onthe transceiver 1 and the transceiver 2, respectively. The first SSM maybe an ESMC PDU that is sent by the router 12 and that is received by therouter 13 through the port 1. The second SSM may be an ESMC PDU that issent by the router 15 and that is received by the router 13 through theport 2. The router 15 supports G.8264/Y.1364 and G.8264/Y.1364 Amendment2. The router 15 is a free running clock, and an SSM code included inthe ESMC PDU sent by the router 15 indicates the quality level of thesecond clock source (the router 15). For example, a value of the SSMcode is 0xB. The quality level of the router 15 is QL-EEC1. The router15 supports G.8264/Y.1364 Amendment 2, and a value of an eSSM codeincluded in the SSM sent by the router 15 is equal to 0xFF. The router12 supports G.8264/Y.1364 and G.8264/Y.1364 Amendment 2. When the router12 does not track the router 11, the router 12 is a free running clock.An SSM code included in the ESMC PDU sent by the router 12 indicates thequality level of the first clock source (the router 12). A value of theSSM code is 0x4, which indicates that the quality level of the router 12is QL-SSU-A. The router 12 supports G.8264/Y.1364 Amendment 2, and avalue of an eSSM code included in the ESMC PDU sent by the router 12 is0xFF.

After the transceiver 1 receives an Ethernet frame that includes theESMC PDU and that is sent by the router 12, the network processor mayparse the Ethernet frame, to determine that the Ethernet frame includesthe ESMC PDU. The network processor sends the ESMC PDU to the controlboard by using the control channel. After receiving the ESMC PDU, thereceiver of the control board sends the ESMC PDU to the centralprocessing unit. The central processing unit determines that qualitylevel information carried in the ESMC PDU is quality level informationof the router 12. The central processing unit may determine that theport 1 corresponding to the transceiver 1 is a port for receiving timinginformation sent by the router 12.

After the transceiver 1 receives an Ethernet frame that includes theESMC PDU and that is sent by the router 15, the network processor mayparse the Ethernet frame, to determine that the Ethernet frame includesthe ESMC PDU. The network processor sends the ESMC PDU to the controlboard by using the control channel. After receiving the ESMC PDU, thereceiver of the control board sends the ESMC PDU to the centralprocessing unit. The central processing unit may determine that qualitylevel information carried in the ESMC PDU is quality level informationof the router 15. The central processing unit may determine that theport 2 corresponding to the transceiver 2 is a port for receiving timinginformation sent by the router 15.

In addition, the memory stores a computer program or code for executingG.8264/Y.1364 and G.8264/Y.1364 Amendment 2.

The central processing unit may perform the following operations byexecuting the computer program or the code. The central processing unitparses the ESMC PDUs sent by the router 12 and by the router 15, toobtain an SSM code and an eSSM code for indicating the quality level ofthe router 12 and obtain an SSM code and an eSSM code for indicating thequality level of the router 15. By comparing a value of the SSM code forindicating the quality level of the router 12 with a value of the SSMcode for indicating the quality level of the router 15, it is determinedthat the value of the SSM code for indicating the quality level of therouter 12 is less than the value of the SSM code for indicating thequality level of the router 15. Based on a fact that the value of theSSM code for indicating the quality level of the router 12 is less thanthe value of the SSM code for indicating the quality level of the router15, it is determined that the quality level of the router 12 is higherthan that of the router 15. The central processing unit configures thetransceiver 1, so that the port 1 sends the received timing informationof the router 12 to the control board by using the control channel.

In a possible implementation, the first clock source is the router 11.The second clock source is the router 14. The first SSM may be an ESMCPDU that is sent by the router 12 and that is received by the router 13through the port 1. The second SSM may be an ESMC PDU that is sent bythe router 15 and that is received by the router 13 through the port 2.The router 15 supports G.8264/Y.1364 and G.8264/Y.1364 Amendment 2. Therouter 15 tracks time and a frequency of the router 14. An SSM codeincluded in the ESMC PDU sent by the router 15 indicates the qualitylevel of the second clock source (the router 14). For example, a valueof the SSM code is 0x4. The quality level of the router 14 is QL-SSU-A.The router 15 supports G.8264/Y.1364 Amendment 2, and a value of an eSSMcode included in the SSM sent by the router 15 is equal to 0xFF. Therouter 12 supports G.8264/Y.1364 and G.8264/Y.1364 Amendment 2. Therouter 12 tracks time and a frequency of the router 11. An SSM codeincluded in the ESMC PDU sent by the router 12 indicates the qualitylevel of the first clock source (the router 11). A value of the SSM codeis 0x2, which indicates that the quality level of the router 11 isQL-PRC. Because the router 12 supports G.8264/Y.1364 Amendment 2, avalue of an eSSM code included in the ESMC PDU sent by the router 12 is0xFF.

After the transceiver 1 receives an Ethernet frame that includes theESMC PDU and that is sent by the router 12, the network processor mayparse the Ethernet frame, to determine that the Ethernet frame includesthe ESMC PDU. The network processor sends the ESMC PDU to the controlboard by using the control channel. After receiving the ESMC PDU, thereceiver of the control board sends the ESMC PDU to the centralprocessing unit. The central processing unit determines that qualitylevel information carried in the ESMC PDU is quality level informationof the router 11. The central processing unit may determine that theport 1 corresponding to the transceiver 1 is a port for receiving timinginformation sent by the router 11.

After the transceiver 1 receives an Ethernet frame that includes theESMC PDU and that is sent by the router 15, the network processor mayparse the Ethernet frame, to determine that the Ethernet frame includesthe ESMC PDU. The network processor sends the ESMC PDU to the controlboard by using the control channel. After receiving the ESMC PDU, thereceiver of the control board sends the ESMC PDU to the centralprocessing unit. The central processing unit may determine that qualitylevel information carried in the ESMC PDU is quality level informationof the router 14. The central processing unit may determine that theport 2 corresponding to the transceiver 2 is a port for receiving timinginformation sent by the router 14.

In addition, the memory stores a computer program for executingG.8264/Y.1364 and G.8264/Y.1364 Amendment 2. The central processing unitmay perform the following operations by executing the computer program.The central processing unit parses the ESMC PDUs sent by the router 12and by the router 15, to obtain an SSM code and an eSSM code forindicating a quality level of the router 11 and obtain an SSM code forindicating a quality level of the router 14. By comparing a value of theSSM code for indicating the quality level of the router 11 with a valueof the SSM code for indicating the quality level of the router 14, it isdetermined that the value of the SSM code for indicating the qualitylevel of the router 11 is less than the value of the SSM code forindicating the quality level of the router 14. Based on a fact that thevalue of the SSM code for indicating the quality level of the router 11is less than the value of the SSM code for indicating the quality levelof the router 14, it is determined that the quality level of the router11 is higher than that of the router 14. The central processing unitconfigures the transceiver 1, so that the port 1 sends the receivedtiming information of the router 11 to the control board by using thecontrol channel.

Specifically, the transceiver 1 includes the physical layer device. Thephysical layer device includes a circuit for executing clock recovery.After the transceiver 1 receives a data flow from the router 12, thecircuit for executing the clock recovery can obtain timing informationfrom the data flow. For example, the timing information may be aphysical timing flow. For the physical timing flow, refer to thedescription in G.8264/Y.1364. Timing information is a periodic signal.Because the periodic signal is to be input to the phase-locked loop, theperiodic signal herein is referred to as a periodic input signal. Thetransceiver 1 sends the timing information to the control board by usingthe control channel. Specifically, the receiver sends the timinginformation to the phase-locked loop. The phase-locked loop generates aperiodic output signal based on the timing information, and a phase ofthe periodic output signal is the same as a phase of the periodic inputsignal included in the timing information. The control board sends theperiodic output signal to the transceiver 3 by using the transmitter.For example, the periodic output signal may be T0. For T0, refer to thedescription of T0 in Figure A.2 in G.8264/Y.1364. The periodic outputsignal is a reference clock signal of the transceiver 3. Specifically,the physical layer device in the transceiver 3 processes, based on thereference clock signal, an Ethernet frame provided by the networkprocessor. For example, the physical layer device in the transceiver 3may perform processing such as physical layer encoding, scrambling,virtual lane distribution, and alignment insertion. After processing theEthernet frame, the physical layer device in the transceiver 3 may senda data flow to the base station 16 through the port 3.

Optionally, the method shown in FIG. 3 may further include: calibrating,by the network device, the frequency of the network device based on thetiming signal of the first clock source when the value of the first SSMcode is equal to the value of the second SSM code and the value of thefirst eSSM code is less than the value of the second eSSM code.

For example, assuming that the quality level of the first clock sourceis QL-PRTC and the quality level of the second clock source is QL-PRC,the value of the first SSM code is equal to 0x2, and the value of thesecond SSM code is equal to 0x2. The value of the first eSSM code isequal to 0x20, and the value of the second eSSM code is equal to 0xFF.That is, when the value of the first SSM code is equal to the value ofthe second SSM code, if determining is based only on the values of theSSM codes, the quality level of the first clock source is equal to thequality level of the second clock source. However, the quality level ofthe first clock source is actually higher than the quality level of thesecond clock source.

Therefore, in the foregoing technical solution, when the value of thefirst SSM code is equal to the value of the second SSM code, the clocksource with higher precision can be determined based on the values ofthe eSSM codes.

Optionally, the method shown in FIG. 3 may further include: calibrating,by the network device, the frequency of the network device based on thetiming signal of the first clock source when the value of the first SSMcode is equal to the value of the second SSM code, the value of thefirst eSSM code is equal to the value of the second eSSM code, and avalue of the number of cascaded synchronous Ethernet equipment clocksfrom a nearest synchronization supply unit/primary (reference clocknumber of cascaded EECs from the nearest SSU/PRC) in the first SSM isless than a value of the number of cascaded EECs from the nearestSSU/PRC in the second SSM.

In the foregoing technical solution, when the value of the first SSMcode is equal to the value of the second SSM code and the value of thefirst eSSM code is equal to the value of the second eSSM code, thenetwork device can select, from a plurality of clock sources, a clocksource for calibrating the frequency of the network device, to avoid afailure to determine the clock source. For example, the failure todetermine the clock source may result in low precision of a clock of thenetwork device, and may even result in a service interruption of thenetwork device.

Optionally, the method shown in FIG. 3 may further include: calibrating,by the network device, the frequency of the network device based on thetiming signal of the first clock source when the value of the first SSMcode is equal to the value of the second SSM code, the value of thefirst eSSM code is equal to the value of the second eSSM code, a valueof the number of cascaded synchronous Ethernet equipment clocks from thenearest synchronization supply unit/primary reference clock in the firstSSM is equal to a value of the number of cascaded synchronous Ethernetequipment clocks from the nearest synchronization supply unit/primaryreference clock in the first SSM, and a value of the number of cascadedeEECs from the nearest SSU/PRC in the first SSM is less than a value ofthe number of cascaded eEECs from the nearest SSU/PRC in the second SSM.

Optionally, in the foregoing technical solution, the method may furtherinclude: calibrating, by the network device, the frequency of thenetwork device based on the timing signal of the first clock source whenthe value of the first SSM code is equal to the value of the second SSMcode, the value of the first eSSM code is equal to the value of thesecond eSSM code, the value of the number of cascaded synchronousEthernet equipment clocks from the nearest synchronization supplyunit/primary reference clock in the first SSM is equal to the value ofthe number of cascaded synchronous Ethernet equipment clocks from thenearest synchronization supply unit/primary reference clock in thesecond SSM, a value of the number of cascaded eEECs from the nearestSSU/PRC in the first SSM is equal to a value of the number of cascadedenhanced synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the second SSM,and a value of a synchronous Ethernet master identity SyncE Master ID inthe first SSM is less than a value of a synchronous Ethernet masteridentity SyncE Master ID in the second SSM.

For example, in the foregoing technical solution, the network device isa synchronous Ethernet equipment clock or a synchronous opticaltransport network equipment clock.

FIG. 5 is a schematic structural diagram of a network device 500.Referring to FIG. 5, the network device includes a receiving unit 501and a calibration unit 502. For example, the network device 500 may bespecifically the network device shown in FIG. 4. For a specificimplementation of the network device 500, refer to the description inthe embodiment corresponding to FIG. 4. The network device 500 mayperform the method shown in FIG. 3. For a specific implementation of thenetwork device 500, refer to the description in the embodimentcorresponding to FIG. 3.

The receiving unit 501 is configured to receive a first SSM and a secondSSM.

The first SSM carries a first SSM code for indicating a quality level ofa first clock source and a first eSSM code for indicating the qualitylevel of the first clock source, and the second SSM carries a second SSMcode for indicating a quality level of a second clock source and asecond eSSM code for indicating the quality level of the second clocksource.

For example, the receiving unit 501 may be configured to perform S301.For a specific implementation of the receiving unit 501, refer to thedescription of S301 in the embodiment shown in FIG. 3.

For example, the receiving unit 501 may specifically include thetransceiver 1 and the transceiver 2 in FIG. 4. For example, the networkdevice 500 may be the router 13 in FIG. 2. The router 13 may receive,through the port 1, the first SSM sent by the router 12, and mayreceive, through the port 2, the second SSM sent by the router 15.

The calibration unit 502 is configured to: calibrate a frequency of thenetwork device based on a timing signal of the first clock source when avalue of the first SSM code is less than a value of the second SSM code.

For example, the calibration unit 502 may be configured to perform S302.For a specific implementation of the calibration unit 502, refer to thedescription of S302 in the embodiment shown in FIG. 3.

For example, the calibration unit 502 may include the phase-locked loopin FIG. 4. The phase-locked loop may receive the timing signal of thefirst clock source by using the transceiver 1. The calibrating afrequency of the network device based on a timing signal of the firstclock source may be specifically generating a system clock signal basedon the timing signal of the first clock source. A frequency of thesystem clock signal is equal to a frequency of the timing signal of thefirst clock source. The system clock signal can drive a component in thenetwork device. For example, the component in the network device may bean interface board or a physical layer device. An operation ofdetermining that the value of the first SSM code is less than the valueof the second SSM code may be performed by the central processing unitin FIG. 4.

Optionally, the calibration unit 502 is further configured to: calibratethe frequency of the network device based on the timing signal of thefirst clock source when the value of the first SSM code is equal to thevalue of the second SSM code and a value of the first eSSM code is lessthan a value of the second eSSM code.

Optionally, the calibration unit 502 is further configured to: calibratethe frequency of the network device based on the timing signal of thefirst clock source when the value of the first SSM code is equal to thevalue of the second SSM code, the value of the first eSSM code is equalto the value of the second eSSM code, and a value of the number ofcascaded synchronous Ethernet equipment clocks from a nearestsynchronization supply unit/primary (reference clock number of cascadedEECs from the nearest SSU/PRC) in the first SSM is less than a value ofthe number of cascaded synchronous Ethernet equipment clocks from thenearest synchronization supply unit/primary reference clock in thesecond SSM.

Optionally, the calibration unit 502 is further configured to: calibratethe frequency of the network device based on the timing signal of thefirst clock source when the value of the first SSM code is equal to thevalue of the second SSM code, the value of the first eSSM code is equalto the value of the second eSSM code, the value of the number ofcascaded synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the first SSM isequal to the value of the number of cascaded synchronous Ethernetequipment clocks from the nearest synchronization supply unit/primaryreference clock in the second SSM, and a value of the number of cascadedenhanced synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary (reference clock number of cascadedeEECs from the nearest SSU/PRC) in the first SSM is less than a value ofthe number of cascaded enhanced synchronous Ethernet equipment clocksfrom the nearest synchronization supply unit/primary reference clock inthe second SSM.

Optionally, the calibration unit 502 is further configured to calibratethe frequency of the network device based on the timing signal of thefirst clock source when the value of the first SSM code is equal to thevalue of the second SSM code, the value of the first eSSM code is equalto the value of the second eSSM code, the value of the number ofcascaded synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary reference clock in the first SSM isequal to the value of the number of cascaded synchronous Ethernetequipment clocks from the nearest synchronization supply unit/primaryreference clock in the second SSM, the value of the number of cascadedenhanced synchronous Ethernet equipment clocks from the nearestsynchronization supply unit/primary (reference clock number of cascadedeEECs from the nearest SSU/PRC) in the first SSM is equal to the valueof the number of cascaded enhanced synchronous Ethernet equipment clocksfrom the nearest synchronization supply unit/primary reference clock inthe second SSM, and a value of a synchronous Ethernet master identitySyncE Master ID in the first SSM is less than a value of a synchronousEthernet master identity SyncE Master ID in the second SSM.

Optionally, the network device 500 is a synchronous Ethernet equipmentclock or a synchronous optical transport network equipment clock.

FIG. 6 is a schematic structural diagram of a network device. Thenetwork device 600 includes a transceiver 601, a processor 602, and amemory 603. The transceiver 601 is coupled to the processor 602, and theprocessor 602 is coupled to the memory 603. The memory 603 stores acomputer program.

The transceiver 601 is configured to receive a first SSM and a secondSSM.

The first SSM carries a first SSM code for indicating a quality level ofa first clock source and a first eSSM code for indicating the qualitylevel of the first clock source, and the second SSM carries a second SSMcode for indicating a quality level of a second clock source and asecond eSSM code for indicating the quality level of the second clocksource.

When the computer program in the memory 603 is executed by the processor602 or another device or another component of the network device, theprocessor 602 is enabled to calibrate a frequency of the network device600 based on a timing signal of the first clock source when a value ofthe first SSM code is less than a value of the second SSM code.

For example, the network device 600 may be the network device 500 shownin FIG. 5. The network device 600 may perform the method shown in FIG.3. The network device 600 may be the network device 400 shown in FIG. 4.The network device 600 may be the router 13 shown in FIG. 2.

For example, the transceiver 601 may be configured to perform S301. Fora specific implementation of the transceiver 601, refer to thedescription of S301 in the embodiment shown in FIG. 3. For example, thetransceiver 601 may include the transceiver 1 and the transceiver 2 inthe network device 400 shown in FIG. 4.

For example, the processor 602 may be configured to perform S302. For aspecific implementation of the processor 602, refer to the descriptionof S302 in the embodiment shown in FIG. 3. For example, the processor602 may include the central processing unit and the phase-locked loop inFIG. 4. The central processing unit is configured to determine that thevalue of the first SSM code is less than the value of the second SSMcode. The phase-locked loop is configured to calibrate the frequency ofthe network device 600. The central processing unit may be furtherconfigured to determine that the first clock source is a clock sourcethat needs to be tracked by the network device 600. The memory 603 mayinclude the memory in FIG. 4.

FIG. 7 is a schematic structural diagram of a system. Referring to FIG.7, a system 700 includes a network device 701, a first clock source 702,and a second clock source 703. The network device 701 may be the networkdevice 600 shown in FIG. 6, the network device 500 shown in FIG. 5, orthe network device 400 shown in FIG. 4. The network device 701 mayperform the method shown in FIG. 3. For a specific implementation of thenetwork device 701, refer to the descriptions in the embodimentscorresponding to FIG. 3, FIG. 4, FIG. 5, and FIG. 6. Details are notdescribed herein.

In addition, the system 700 shown in FIG. 7 may be applied to thenetwork shown in FIG. 2. For example, the first clock source 702 may bea router 11. The second clock source 703 may be a router 15. The networkdevice 701 may be a router 13. The router 11 is a clock source of therouter 12. The router 12 tracks a frequency of the router 11. The router15 does not track a router 14. The router 15 is a free running clock.For a specific implementation in which the system 700 shown in FIG. 7 isapplied to the network shown in FIG. 2, refer to the description in theembodiment corresponding to FIG. 2.

This disclosure provides a computer program product. The computerprogram product is stored in a non-volatile computer readable storagemedium or a volatile computer readable storage medium. When the computerprogram is executed by a processor, or another device or component, theprocessor is configured to perform the method shown in FIG. 3.

It should be understood that sequence numbers of the foregoing processesdo not mean execution sequences in various embodiments. The executionsequences of the processes should be determined by functions andinternal logic of the processes, and should not be construed as anylimitation on the implementation processes of the embodiments.

A person of ordinary skill in the art may be aware that, in combinationwith the examples described in the embodiments disclosed in thisspecification, units and steps may be implemented by electronic hardwareor a combination of computer software and electronic hardware. Whetherthe functions are performed by hardware or a combination of software andelectronic hardware depends on particular applications and designconstraint conditions of the technical solutions. A person skilled inthe art may use different methods to implement the described functionsfor each particular application, but it should not be considered thatthe implementation goes beyond the scope of this disclosure.

It may be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, for a detailed workingprocess of the foregoing system, apparatus, and unit, reference may bemade to a corresponding process in the foregoing method embodiments, anddetails are not described herein again.

In the several embodiments provided, it should be understood that thedisclosed system, apparatus, and method may be implemented in othermanners. For example, the described apparatus embodiment is merely anexample. For example, the unit division is merely logical functiondivision and may be other division in actual implementation. Forexample, a plurality of units or components may be combined orintegrated into another system, or some features may be ignored or notperformed. In addition, the displayed or discussed mutual couplings ordirect couplings or communication connections may be implemented byusing some interfaces. The indirect couplings or communicationconnections between the apparatuses or units may be implemented inelectronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments may be integrated intoone processing unit, or each of the units may exist alone physically, ortwo or more units are integrated into one unit. The integrated unit maybe implemented in a form of hardware, or may be implemented in a form ofelectronic hardware and software.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions essentially, orsome of the technical solutions may be implemented in a form of asoftware product. The computer software product is stored in a storagemedium, and includes several instructions for instructing a processor ora computer device (which may be a personal computer, a server, a networkdevice, or the like) to perform all or some of the steps of the methodsdescribed in the embodiments. The foregoing storage medium includes: anymedium that can store program code, such as a USB flash drive, aremovable hard disk, a read-only memory (ROM), a random-access memory(RAM), a magnetic disk, or an optical disc.

What is claimed is:
 1. A method implemented by a network device andcomprising: receiving a first synchronization status message (SSM) and asecond SSM, wherein the first SSM carries a first SSM code forindicating a first quality level of a first clock source and a firstenhanced SSM (eSSM) code for indicating the first quality level, andwherein the second SSM carries a second SSM code for indicating a secondquality level of a second clock source and a second eSSM code forindicating the second quality level; and calibrating a frequency of thenetwork device based on a timing signal of the first clock source when afirst value of the first SSM code is less than a second value of thesecond SSM code.
 2. The method of claim 1, further comprisingcalibrating the frequency based on the timing signal when the firstvalue is equal to the second value and a third value of the first eSSMcode is less than a fourth value of the second eSSM code.
 3. The methodof claim 1, further comprising calibrating the frequency based on thetiming signal when the first value is equal to the second value, a thirdvalue of the first eSSM code is equal to a fourth value of the secondeSSM code, and a first number of cascaded synchronous Ethernet equipmentclocks (EECs) from a first nearest synchronization supply unit/primaryreference clock (SSU/PRC) in the first SSM is less than a second numberof cascaded synchronous EECs from a second nearest SSU/PRC in the secondSSM.
 4. The method of claim 1, further comprising calibrating thefrequency based on the timing signal when the first value is equal tothe second value, a third value of the first eSSM code is equal to afourth value of the second eSSM code, a first number of cascadedsynchronous Ethernet equipment clocks (EECs) from a first nearestsynchronization supply unit/primary reference clock (SSU/PRC) in thefirst SSM is equal to a second number of cascaded synchronous EECs froma second nearest SSU/PRC in the second SSM, and a third number ofcascaded enhanced synchronous EECs from the first nearest SSU/PRC isless than a fourth number of cascaded enhanced synchronous EECs from thesecond nearest SSU/PRC.
 5. The method of claim 1, further comprisingcalibrating the frequency based on the timing signal when the firstvalue is equal to the second value, a third value of the first eSSM codeis equal to a fourth value of the second eSSM code, a first number ofcascaded synchronous Ethernet equipment clocks (EECs) from a firstnearest synchronization supply unit/primary reference clock (SSU/PRC) inthe first SSM is equal to a second number of cascaded synchronous EECsfrom a second nearest SSU/PRC in the second SSM, a third number ofcascaded enhanced synchronous EECs from the first nearest SSU/PRC isequal to a fourth number of cascaded enhanced synchronous EECs from thesecond nearest SSU/PRC, and a fifth value of a synchronous Ethernetmaster identity (SyncE master ID) in the first SSM is less than a sixthvalue of a SyncE master ID in the second SSM.
 6. The method of claim 1,wherein the first quality level is one of quality level-primaryreference clock (QL-PRC), quality level-type I or V slave clock(QL-SSU-A), quality level-type VI slave clock (QL-SSU-B), qualitylevel-synchronous equipment clock (QL-SEC), or quality level-do not use(QL-DNU).
 7. The method of claim 6, wherein the second quality level isone of QL-PRC, QL-SSU-A, QL-SSU-B, QL-SEC, or QL-DNU.
 8. A networkdevice comprising: a memory configured to store instructions; and aprocessor coupled to the memory and configured to execute theinstructions to: receive a first synchronization status message (SSM)and a second SSM, wherein the first SSM carries a first SSM code forindicating a first quality level of a first clock source and a firstenhanced SSM (eSSM) code for indicating the first quality level, andwherein the second SSM carries a second SSM code for indicating a secondquality level of a second clock source and a second eSSM code forindicating the second quality level; and calibrate a frequency of thenetwork device based on a timing signal of the first clock source when afirst value of the first SSM code is less than a second value of thesecond SSM code.
 9. The network device of claim 8, wherein the processoris further configured to calibrate the frequency based on the timingsignal when the first value is equal to the second value and a thirdvalue of the first eSSM code is less than a fourth value of the secondeSSM code.
 10. The network device of claim 8, wherein the processor isfurther configured to calibrate the frequency based on the timing signalwhen the first value is equal to the second value, a third value of thefirst eSSM code is equal to a fourth value of the second eSSM code, anda first number of cascaded synchronous Ethernet equipment clocks (EECs)from a first nearest synchronization supply unit/primary reference clock(SSU-PRC) in the first SSM is less than a second number of cascadedsynchronous EECs from a second nearest SSU/PRC in the second SSM. 11.The network device of claim 8, wherein the processor is furtherconfigured to calibrate the frequency based on the timing signal whenthe first value is equal to the second value, a third value of the firsteSSM code is equal to a fourth value of the second eSSM code, a firstnumber of cascaded synchronous Ethernet equipment clocks (EECs) from afirst nearest synchronization supply unit/primary reference clock(SSU/PRC) in the first SSM is equal to a second number of cascadedsynchronous EECs from a second nearest SSU/PRC in the second SSM, and athird number of cascaded enhanced synchronous EECs from the firstnearest SSU/PRC is less than a fourth number of cascaded enhancedsynchronous EECs from the second nearest SSU/PRC.
 12. The network deviceof claim 8, wherein the processor is further configured to calibrate thefrequency based on the timing signal when the first value is equal tothe second value, a third value of the first eSSM code is equal to afourth value of the second eSSM code, a first number of cascadedsynchronous Ethernet equipment clocks (EECs) from a first nearestsynchronization supply unit/primary reference clock (SSU/PRC) in thefirst SSM is equal to a second number of cascaded synchronous EECs froma second nearest SSU/PRC in the second SSM, a third number of cascadedenhanced synchronous EECs from the first nearest SSU/PRC is equal to afourth number of cascaded enhanced synchronous EECs from the secondnearest SSU/PRC, and a fifth value of a synchronous Ethernet masteridentity (SyncE master ID) in the first SSM is less than a sixth valueof a SyncE master ID in the second SSM.
 13. The network device of claim8, wherein the first quality level is one of quality level-primaryreference clock (QL-PRC), quality level-type I or V slave clock(QL-SSU-A), quality level-type VI slave clock (QL-SSU-B), qualitylevel-synchronous equipment clock (QL-SEC), or quality level-do not use(QL-DNU).
 14. The network device of claim 13, wherein the second qualitylevel is one of QL-PRC, QL-SSU-A, QL-SSU-B, QL-SEC, or QL-DNU.
 15. Acomputer program product comprising instructions for storage on anon-transitory medium and that, when executed by a processor, cause anetwork device to: receive a first synchronization status message (SSM)and a second SSM, wherein the first SSM carries a first SSM code forindicating a first quality level of a first clock source and a firstenhanced SSM (eSSM) code for indicating the first quality level, andwherein the second SSM carries a second SSM code for indicating a secondquality level of a second clock source and a second eSSM code forindicating the second quality level; and calibrate a frequency of thenetwork device based on a timing signal of the first clock source when afirst value of the first SSM code is less than a second value of thesecond SSM code.
 16. The computer program product of claim 15, whereinthe instructions further cause the network device to calibrate thefrequency based on the timing signal when the first value is equal tothe second value and a third value of the first eSSM code is less than afourth value of the second eSSM code.
 17. The computer program productof claim 15, wherein the instructions further cause the network deviceto calibrate the frequency based on the timing signal when the firstvalue is equal to the second value, a third value of the first eSSM codeis equal to a fourth value of the second eSSM code, and a first numberof cascaded synchronous Ethernet equipment clocks (EECs) from a firstnearest synchronization supply unit/primary reference clock (SSU/PRC) inthe first SSM is less than a second number of cascaded synchronous EECsfrom a second nearest SSU/PRC in the second SSM.
 18. The computerprogram product of claim 15, wherein the instructions further cause thenetwork device to calibrate the frequency based on the timing signalwhen the first value is equal to the second value, a third value of thefirst eSSM code is equal to a fourth value of the second eSSM code, afirst number of cascaded synchronous Ethernet equipment clocks (EECs)from a first nearest synchronization supply unit/primary reference clock(SSU/PRC) in the first SSM is equal to a second number of cascadedsynchronous EECs from a second nearest SSU/PRC in the second SSM, and athird number of cascaded enhanced synchronous EECs from the firstnearest SSU/PRC is less than a fourth number of cascaded enhancedsynchronous EECs from the second nearest SSU/PRC.
 19. The computerprogram product of claim 15, wherein the instructions further cause thenetwork device to calibrate the frequency based on the timing signalwhen the first value is equal to the second value, a third value of thefirst eSSM code is equal to a fourth value of the second eSSM code, afirst number of cascaded synchronous Ethernet equipment clocks (EECs)from a first nearest synchronization supply unit/primary reference clock(SSU/PRC) in the first SSM is equal to a second number of cascadedsynchronous EECs from a second nearest SSU/PRC in the second SSM, athird number of cascaded enhanced synchronous EECs from the firstnearest SSU/PRC is equal to a fourth number of cascaded enhancedsynchronous EECs from the second nearest SSU/PRC, and a fifth value of asynchronous Ethernet master identity (SyncE master ID) in the first SSMis less than a sixth value of a SyncE master ID in the second SSM. 20.The computer program product of claim 15, wherein the first qualitylevel is one of quality level-primary reference clock (QL-PRC), qualitylevel-type I or V slave clock (QL-SSU-A), quality level-type VI slaveclock (QL-SSU-B), quality level-synchronous equipment clock (QL-SEC), orquality level-do not use (QL-DNU), and wherein the second quality levelis one of QL-PRC, QL-SSU-A, QL-SSU-B, QL-SEC, or QL-DNU.